#ifndef RUSSIATETRIX_H
#define RUSSIATETRIX_H

#include <QPainter>
#include "toybricks.h"

#define RUSSIA_TETRIX_SIZE 20

enum GameStatus{
    STOP,
    RUNNING,
    PAUSE,
    GAMEOVER
};

class RussiaTetrix
{
public:
    RussiaTetrix();
    RussiaTetrix(quint8 row,quint8 col);

    qint8 X() const {return _posX;}
    qint8 Y() const {return _posY;}

    void clearPiece() { _piece.clean(); _posX = _posY = 0;}
    void changePiece(qint8 x = 5,qint8 y = 0) {_piece = ToyBricks::createTetrixPiece(); _posX = x; _posY = y - _piece.height();}

    bool moveLeft();
    bool moveRight();
    bool dropDown();
    bool rotateLeft();

    bool isRunning() const {return _status == RUNNING;}
    bool isPause() const {return _status == PAUSE;}
    bool isGameOver() const {return _status == GAMEOVER;}
    void setGameStatus(GameStatus gs) {_status = gs;}

    quint32 getRemovedLine() const {return _remove_line;}

    quint8 removeCompletedLine();
    bool isCollision(MoveDirection direction);
    void handelCollision();

    void draw(QPainter &painter,const QPoint &point);
private:
    qint8 _posX;
    qint8 _posY;
    quint32 _remove_line;

    GameStatus _status;
    ToyBricks _piece;
    ToyBricks _container;
};

#endif // RUSSIATETRIX_H
